import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import CompanyIntro from '@/views/Company/CompanyIntro.vue'
import CompanyCulture from '@/views/Company/CompanyCulture.vue'
import CompanyNews from '@/views/NewsCenter/CompanyNews.vue'
import TradeNews from '@/views/NewsCenter/TradeNews.vue'
import Production from '@/views/Production/Production.vue'
import Service from '@/views/Service/Service.vue'
import Intelligence from '@/views/Intelligence/Intelligence.vue'
import NewList from '@/views/NewsCenter/NewList/NewList.vue'
import ProductionList from '@/views/Production/ProductionList/ProductionList.vue'

Vue.use(VueRouter)

const routes = [
        { path: '/', redirect: '/Home' },
        {
            path: '/Home',
            name: 'Home',
            // redirect: '/Home',
            component: Home,
        },
        { path: '/CompanyIntro', component: CompanyIntro },
        { path: '/CompanyCulture', component: CompanyCulture },
        { path: '/CompanyNews', component: CompanyNews },
        { path: '/TradeNews', component: TradeNews },
        { path: '/Production', component: Production },
        { path: '/Service', component: Service },
        { path: '/Intelligence', component: Intelligence },
        { path: '/NewList/:index?', component: NewList },
        { path: '/ProductionList/:index?', component: ProductionList },

    ]
    // 防止点击相同路由报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
    routes
})

export default router